package com.example.demo.test.leetcode.day1122;

import java.util.Arrays;

public class Solution01 {
    public static void main(String[] args) {
        //  System.out.println(isAnagram("anagram", "nagaram"));
        // char[] a = {'a', 'b', 'c', 'z', '+', '-', '0', 'A', 'K', 'n', 't', 'm'};

        long temp=12345678999L;
//        System.out.println(Integer.MAX_VALUE);
  //      System.out.println(temp > Integer.MAX_VALUE);
        System.out.println(reverse(1234567899));
    }

    public static boolean isAnagram(String s, String t) {
        char[] charsS = s.toCharArray();
        char[] charsT = t.toCharArray();
        Arrays.sort(charsS);
        Arrays.sort(charsT);
        return Arrays.equals(charsS, charsT);
    }

    public static char[] reverseString(char[] s) {
        int i = 0;
        int j = s.length - 1;
        while (i < j) {
            char temp = s[i];
            s[i++] = s[j];
            s[j--] = temp;
        }
        return s;
    }

    public static int reverse(int x) {

        long res = 0;
        long temp;
        while (x != 0) {
            temp= 10 * res + x % 10;
            if (temp < Integer.MIN_VALUE || temp > Integer.MAX_VALUE)
                return 0;
            res = 10 * res + x % 10;
            x = x / 10;
        }
        return (int) res;
    }
}
